package com.geeklei.media.ui.menu.popup;

import android.content.Context;
import android.widget.BaseAdapter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public abstract class AbsGroupAdapter<T> extends BaseAdapter {
    private final Context mContext;
    private List<T> mGroup = new ArrayList();

    public AbsGroupAdapter(Context context) {
        this.mContext = context;
    }

    public Context getContext() {
        return this.mContext;
    }

    public boolean isEmpty() {
        return this.mGroup.isEmpty();
    }

    public void clear() {
        this.mGroup.clear();
        notifyDataSetChanged();
    }

    public void setGroup(List<T> list) {
        this.mGroup.clear();
        if (list != null && list.size() > 0) {
            this.mGroup.addAll(list);
        }
        notifyDataSetChanged();
    }

    public void setGroup(T[] tArr) {
        setGroup(Arrays.asList(tArr));
    }

    public void addGroup(List<T> list) {
        if (list != null && list.size() > 0) {
            this.mGroup.addAll(list);
            notifyDataSetChanged();
        }
    }

    public void addGroup(T[] tArr) {
        addGroup(Arrays.asList(tArr));
    }

    public void addItem(T t) {
        if (t != null) {
            this.mGroup.add(t);
            notifyDataSetChanged();
        }
    }

    public List<T> getGroup() {
        return this.mGroup;
    }

    public int getCount() {
        return this.mGroup.size();
    }

    public Object getItem(int i) {
        if (i < 0 || i >= getCount()) {
            return null;
        }
        return this.mGroup.get(i);
    }

    public long getItemId(int i) {
        return 0;
    }
}
